#include "Train.h"

class Solution {
public:
    void sortColors(vector<int>& nums) {
        int n = nums.size();
        int l = -1, r = n, i = 0;
        while (i < r)
        {
            if (nums[i] == 0)swap(nums[++l], nums[i++]);
            else if (nums[i] == 1) i++;
            else if (nums[i] == 2) swap(nums[--r], nums[i]);

        }
    }
};